package com.smalltao.sso.dao;

import com.smalltao.sso.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author smallTao.liu
 * @version V1.0
 * @description
 * @date 2018/11/19 17:31
 */
@Repository
public interface UserRoleRepository extends JpaRepository<UserRole, String> {

    /**
     * 根据用户id获取用户角色
     *
     * @param userUid
     * @return
     */
    List<UserRole> findAllByUserUid(String userUid);

    /**
     * 根据用户id获取用户角色ids
     *
     * @param userUid
     * @return
     */
    @Query(value = "select roleUid from UserRole where userUid = :userUid")
    List<String> findRoleUidByUserUid(@Param("userUid") String userUid);

}
